import { computed } from 'vue'
import type { ApiFormData, Store } from '../types'

export const useApiConfig = (store: Store, apiKey: keyof ApiFormData) => {
  const apiConfig = computed(() => {
    const { apiFilePath } = store.basicFormData
    const functionName = store.apiFormData[apiKey]
    if (!apiFilePath || !functionName) {
      return
    }
    return store.apis[apiFilePath]?.apis[functionName]
  })

  return {
    apiConfig
  }
}
